<h1>Sites List</h1>

<?php $today_offers = $tomorrow_offers = $total_offers = 0 ?>

<a href="https://www.facebook.com/dialog/oauth?client_id=116487325090582&redirect_uri=http://reduceri-cadouri.ro/site&scope=manage_pages,offline_access,publish_stream&response_type=token">fb permission</a>

<?php $access_token = "116487325090582|326e6f23b427d938a1eefed7-533936499|ybzkKfZj3RwtY5dWYsR-Cwnqx7c"; ?>

<a href="https://graph.facebook.com/me/accounts?access_token=<?php echo $access_token ?>">get pages</a>

<?php $page_access_token = "116487325090582|326e6f23b427d938a1eefed7-533936499|182974521721759|dlRfci1bKYcfCYS8KhhOvWgduVg"; ?>

<table class="admin">
  <thead>
    <tr>
      <th>Id</th>
      <th>Logo</th>
      <th>Name</th>
      <th>Url</th>
      <th>Actions</th>
      <th>Oferte azi</th>
      <th>Oferte maine</th>
      <th>Total oferte</th>
    </tr>
  </thead>
  <tbody>
    <?php foreach ($Sites as $Site): ?>
    <tr>
      <td><a href="<?php echo url_for('site/edit?id='.$Site->getId()) ?>"><?php echo $Site->getId() ?></a></td>
      <td><img src="/uploads/sites/<?php echo $Site->getLogo() ?>" /></td>
      <td><?php echo $Site->getName() ?></td>
      <td>
        <a href="<?php echo $Site->getUrl() ?>" target="_blank"><?php echo $Site->getUrl() ?></a>
      </td>
      <td>
        <ul>
          <li><a href="<?php echo url_for('offer/new?site_id='.$Site->getId()) ?>">Add offer</a></li>
          <li><a href="<?php echo url_for('site/urls?site_id='.$Site->getId()) ?>">City urls</a></li>
          <li><a href="<?php echo url_for('site/parse?site_id='.$Site->getId()) ?>">Parse site</a></li>
        </ul>
        </td>
      <td><a href="<?php echo url_for('offer/index?site_id='.$Site->getId().'&date='.date("Y-m-d")) ?>"><?php echo $Site->getCountTodayOffers() ?></a></td>
      <td><?php echo $Site->getCountTomorrowOffers() ?></td>
      <td><a href="<?php echo url_for('offer/index?site_id='.$Site->getId()) ?>"><?php echo $Site->getCountAllOffers() ?></a></td>
    </tr>
    <?php $today_offers += $Site->getCountTodayOffers() ?>
    <?php $tomorrow_offers += $Site->getCountTomorrowOffers() ?>
    <?php $total_offers += $Site->getCountAllOffers() ?>
    <?php endforeach; ?>
    <tr>
      <th></th>
      <th></th>
      <th></th>
      <th></th>
      <th></th>
      <th><?php echo $today_offers ?></th>
      <th><?php echo $tomorrow_offers ?></th>
      <th><?php echo $total_offers ?></th>
    </tr>
  </tbody>
</table>

  <a href="<?php echo url_for('site/new') ?>">New</a>
